package diseaseParser;

public class FileStructure {
	String[] fileNames = new String[]{"PC", "OP", "PF", "PQ", "PR"};

	private int[] primaryDiseaseInit = new int[]{75, 77, 75, 75, 75};
	private int[] primaryDiseaseEnd = new int[]{78, 80, 78, 78, 78};

	private int[] secondaryDiseaseInit = new int[]{81, 81, 81, 81, 81};
	private int[] secondaryDiseaseEnd = new int[]{84, 84, 84, 84, 84};

	private int[] occurrenceDateInit = new int[]{26, 26, 26, 26, 26};
	private int[] occurrenceDateEnd = new int[]{31, 31, 31, 31, 31};

	private int[] cpfInit = new int[]{32, 32, 32, 32, 32};
	private int[] cpfEnd = new int[]{42, 42, 42, 42, 42};

	private int[] birthProvinceInit = new int[]{43, 43, 43, 43, 43};
	private int[] birthProvinceEnd = new int[]{44, 44, 44, 44, 44};

	private int[] zipCodeInit = new int[]{45, 45, 45, 45, 45};
	private int[] zipCodeEnd = new int[]{52, 52, 52, 52, 52};

	private int[] birthdayInit = new int[]{60, 60, 60, 60, 60};
	private int[] birthdayEnd = new int[]{67, 67, 67, 67, 67};

	private int[] genderInit = new int[]{68, 68, 68, 68, 68};
	private int[] genderEnd = new int[]{68, 68, 68, 68, 68};

	public int[] primaryDisease;
	public int[] secondaryDisease;
	public int[] occurrenceDate;
	public int[] cpf;
	public int[] birthProvince;
	public int[] zipCode;
	public int[] birthday;
	public int[] gender;

	private static FileStructure instance;

	private FileStructure(String fileType) {
		int choice = -1;
		if(fileType.equalsIgnoreCase("PC"))
			choice = 0;
		else if(fileType.equalsIgnoreCase("OP"))
			choice = 1;
		else if(fileType.equalsIgnoreCase("PF"))
			choice = 2;
		else if(fileType.equalsIgnoreCase("PQ"))
			choice = 3;
		else if(fileType.equalsIgnoreCase("PR"))
			choice = 4;

		if(choice != -1){
			primaryDisease = new int[]{
					primaryDiseaseInit[choice],
					primaryDiseaseEnd[choice]};
			secondaryDisease = new int[]{
					secondaryDiseaseInit[choice], 
					secondaryDiseaseEnd[choice]};
			occurrenceDate = new int[]{
					occurrenceDateInit[choice],
					occurrenceDateEnd[choice]};
			cpf = new int[]{
					cpfInit[choice],
					cpfEnd[choice]};
			birthProvince = new int[]{
					birthProvinceInit[choice],
					birthProvinceEnd[choice]};
			zipCode = new int[]{
					zipCodeInit[choice],
					zipCodeEnd[choice]};
			birthday = new int[]{
					birthdayInit[choice],
					birthdayEnd[choice]};
			gender = new int[]{
					genderInit[choice],
					genderEnd[choice]};
		} else 
			System.out.println("Deu pau no parser!");
	} 


	public synchronized static FileStructure getInstance(String fileType){
		if(instance == null){
			instance = new FileStructure(fileType);
		}
		return instance;
	}

}
